#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/5/13 10:43
# @USER    : 717-3
# @File    : TwoSum.py
# @Software: PyCharm
# @Version  : Python-3.6
# @TASK:
from typing import List


class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        """
        Given an array of integers, return indices of the two numbers such that they add up to a specific target.
        You may assume that each input would have exactly one solution, and you may not use the same element twice.

        Example:
            Given nums = [2, 7, 11, 15], target = 9,

            Because nums[0] + nums[1] = 2 + 7 = 9,

            return [0, 1].

        :param nums: List[int]
        :param target: int
        :return: List[int]
        """
        for i in range(len(nums)):
            pop_value = target - nums.pop(0)
            if pop_value in nums:
                return [i, nums.index(pop_value) + i + 1]


if __name__ == '__main__':
    # Q1
    S = Solution()
    num = [2, 7, 11, 15]
    targetnum = 9
    print(S.twoSum(num, targetnum))
    print('done')
